<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增团队政策信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-policy-add">
            <input type="hidden" name="type" value="1" readonly>
            <div class="form-group">
                <label class="col-sm-3 control-label">引流政策编号：</label>
                <div class="col-sm-8">
                    <input name="policyId" class="form-control" readonly th:value="${policyId}" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">政策名称：</label>
                <div class="col-sm-8">
                    <input name="policyName"  required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">政策比例：</label>
                <div class="col-sm-8">
                    <input name="policyValue" required onkeyup="value=value.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">引流档：</label>
                <div class="col-sm-8">
                    <select name="policyStage" class="form-control m-b" >
                        <option value="">所有</option>
                        <option value="1">1档</option>
                        <option value="2">2档</option>
                        <option value="3">3档</option>
                        <option value="4">4档</option>
                    </select>
                </div>
            </div>
            <div class="form-group" style="display: none">
                <label class="col-sm-3 control-label">团类型：</label>
                <div class="col-sm-8">
                    <select name="teamType" onchange="rewardTypes(this)" class="form-control m-b">
                        <option value="1">老团</option>
                        <option value="2">新团</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">团奖励类型：</label>
                <div class="col-sm-8">
                    <select name="rewardType" id="rewardType" class="form-control m-b">
                        <option value="">请选择</option>
                        <option value="4">电签</option>
                        <option value="1">传统</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <select name="status" class="form-control m-b" required>
                    <option value="1">正常</option>
                    <option value="0">关闭</option>
                </select>
            </div>
        </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始区间(人数)：</label>
                <div class="col-sm-8">
                    <input name="policyCondition" required onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束区间(人数)：</label>
                <div class="col-sm-8">
                    <input name="policyConditionEnd" required onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate"  required readonly class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDate"  required readonly class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "team/policy"
        $("#form-policy-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-policy-add').serialize());
            }
        }


        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function rewardTypes(type) {
            if(type.value == 2){
                $("#rewardType").removeAttrs("disabled")
            }else{
                $("#rewardType").attr("disabled","disabled")
            }
        }

    </script>
</body>
</html>
